<#assign className = table.className>
<#assign classNameLower = className?uncap_first>
<#assign classNameCap = className?lower_case?cap_first>
package ${basepackage}.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import ${basepackage}.entity.${className};
import ${basepackage}.model.${className}Model;
import ${basepackage}.service.${className}Service;
import ${basepackage}.framework.model.PageData;
import ${basepackage}.framework.model.PageParam;
import ${basepackage}.framework.model.R;

import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;



@Api(tags="${className}接口")
@RestController
@RequestMapping(value="/${className}")
@Slf4j
public class ${className}Controller  {
	
	private final String info_prefix = "[${className}模块]";

	@Autowired
	private ${className}Service ${classNameLower}Service;


	@ApiOperation(value="${className}分页列表")
	@GetMapping(value = "list")
	public R list(PageParam param){
		log.debug("{}-列表数据", info_prefix);
		PageData<${className}Model> data =  ${classNameLower}Service.page(param);
		return R.ok().data(data);
	}


	@ApiOperation(value="${className}详情")
	@GetMapping("/view/{id}")
	public R view(@PathVariable String id){
		log.debug("{}-查看${className}信息", info_prefix);
		${className}Model data = BeanUtil.toBean(${classNameLower}Service.getById(id), ${className}Model.class);
		return R.ok().data(data);
	}
	

	@ApiOperation(value = "新增${className}")
	@PostMapping("add")
	public R add(${className}Model  model) {
		log.debug("{}-新增${className}: {}", info_prefix,  model);
		${className} record = BeanUtil.toBean(model, ${className}.class);
		${classNameLower}Service.insert(record);
		return R.ok("新增成功").data(record);
	}

	
	@ApiOperation(value = "根据ID删除${className}")
	@PostMapping("/del/{id}")
	public R del(@PathVariable String id){
		log.debug("{}-根据ID删除: {}", info_prefix, id);
		${classNameLower}Service.delete(id);
		return R.ok("删除成功");
	}

	
	@ApiOperation(value="更新${className}")
	@PostMapping("update")
	public R update(${className}Model  model){
		log.debug("{}-保存信息: {}", info_prefix, model);
		${className} record = BeanUtil.toBean(model, ${className}.class);
		${classNameLower}Service.update(record);
		return R.ok("更新成功");
	}
	
	@ApiOperation(value = "查看${className}属性")
	@GetMapping("/model")
	public ${className} model() {
		return null;
	}
	
}
